package com.letao.server.dto;

import com.letao.server.entity.MessageInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.format.DateTimeFormatter;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserMessageDTO {
    private Long id;
    private Long userId;
    private Integer msgType;
    private Integer contentType;
    private String content;
    private String createTime;
    private Integer isUnread;

    public UserMessageDTO(MessageInfo messageInfo) {
        this.id = messageInfo.getId();
        this.userId = messageInfo.getUserId();
        this.contentType = messageInfo.getContentType();
        this.msgType = messageInfo.getMsgType();
        this.isUnread = messageInfo.getIsUnread();
        this.content = messageInfo.getContent();
        this.createTime = messageInfo.getCreateTime().format(DateTimeFormatter.ofPattern("MM-dd HH:mm"));
    }
}
